package com.babel.util.result;


import com.babel.util.enums.ResultCodeEnum;

/**
 * 系统内调用
 * @author chenhui
 * @param <T>
 */
public class WsResult<T> {
    private boolean success = true;
    private String msg = "";
    private String code = "200";// codeValue
    private T data;

    public WsResult(){
    }

    public WsResult<T> success(boolean success){
        setSuccess(success);
        return this;
    }
    public WsResult<T> message(String msg){
    	setMsg(msg);
        return this;
    }
    public WsResult<T> code(String code){
        setCode(code);
        return this;
    }
    public WsResult<T> data(T data) {
        setData(data);
        return this;
    }
    public WsResult<T> sucAndData(T data){
        setSuccess(true);
        setCode(ResultCodeEnum.CODE_200.getValue());
        setData(data);
        setMsg("接口请求成功");
        return this;
    }
    
    public WsResult<T> error(ResultCodeEnum resultCodeEnum, String msg){
    	setSuccess(false);
    	setCode(resultCodeEnum.getValue());
    	setMsg(msg);
    	return this;
    }



    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }



}
